/*
 * Retrieve all events
 */

// Create the calendar service object
var calendarService = new google.gdata.calendar.CalendarService('GoogleInc-jsguide-1.0');

// The default "private/full" feed is used to retrieve events from 
// the primary private calendar with full projection 
var feedUri = 'http://www.google.com/calendar/feeds/default/private/full';

// The callback method that will be called when getEventsFeed() returns feed data
var callback = function(result) {       
  
  // Obtain the array of CalendarEventEntry
  var entries = result.feed.entry;    
  
  // Print the total number of events
  PRINT('Total of ' + entries.length + ' event(s)');

  for (var i = 0; i < entries.length; i++ ) {
    var eventEntry = entries[i];
    var eventTitle = eventEntry.getTitle().getText();
    PRINT('Event title = ' + eventTitle);
  }    
}

// Error handler to be invoked when getEventsFeed() produces an error
var handleError = function(error) {
  PRINT(error);
}

// Submit the request using the calendar service object
calendarService.getEventsFeed(feedUri, callback, handleError);
